package wzc.design_pattern.creation.builder;

/**
 * @Author 王振川
 * @Date 2025/7/19
 */

public class Computer {
    private String CPU;
    private String RAM;
    // 存储
    private String storage;
    private String GPU;

    // 私有构造方法，防止直接实例化
    public Computer() {
    }

    // 静态内部类 Builder
    public static class Builder {
        private Computer computer = new Computer();
        public Builder setCPU(String CPU) {
            computer.CPU = CPU;
            return this;
        }
        public Builder setRAM(String RAM) {
            computer.RAM = RAM;
            return this;
        }
        public Builder setStorage(String storage) {
            computer.storage = storage;
            return this;
        }
        public Builder setGPU(String GPU) {
            computer.GPU = GPU;
            return this;
        }

        // 返回最终的 Computer 对象
        public Computer build() {
            return computer;
        }
    }

    public void show() {
        System.out.println("电脑配置：");
        System.out.println("CPU:" + CPU);
        System.out.println("RAM:" + RAM);
        System.out.println("存储:" + storage);
        System.out.println("GPU:" + GPU);
    }
}
